

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>用 FUSE 挂载 CephFS &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/css/custom.css" type="text/css" />

  
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/_sphinx_javascript_frameworks_compat.js"></script>
        <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/doctools.js"></script>
        <script src="../../_static/sphinx_highlight.js"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex/" />
    <link rel="search" title="Search" href="../../search/" />
    <link rel="next" title="在 Windows 上挂载 CephFS" href="../ceph-dokan/" />
    <link rel="prev" title="用内核驱动挂载 CephFS" href="../mount-using-kernel-driver/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../../" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="../">Ceph 文件系统</a></li>
      <li class="breadcrumb-item active">用 FUSE 挂载 CephFS</li>
      <li class="wy-breadcrumbs-aside">
            <a href="../../_sources/cephfs/mount-using-fuse.rst.txt" rel="nofollow"> View page source</a>
      </li>
  </ul>
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../" class="icon icon-home"> Ceph
          

          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../start/">Ceph 简介</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../install/">安装 Ceph</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephadm/">Cephadm</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rados/">Ceph 存储集群</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../">Ceph 文件系统</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../#cephfs">CephFS 入门</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id4">管理</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../#id5">挂载 CephFS</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="../client-config-ref/"> 客户端配置选项</a></li>
<li class="toctree-l3"><a class="reference internal" href="../client-auth/"> 客户端认证</a></li>
<li class="toctree-l3"><a class="reference internal" href="../mount-prerequisites/"> 挂载 CephFS: 前提条件</a></li>
<li class="toctree-l3"><a class="reference internal" href="../mount-using-kernel-driver/"> 用内核驱动挂载 CephFS 文件系统</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#"> 用 FUSE 挂载 CephFS</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id1">前提条件</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id2">提纲</a></li>
<li class="toctree-l4"><a class="reference internal" href="#cephfs">挂载 CephFS</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id3">卸载 CephFS</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id4">永久挂载</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../ceph-dokan/"> 在 Windows 上挂载 CephFS</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../man/8/cephfs-shell/"> CephFS Shell 的用法</a></li>
<li class="toctree-l3"><a class="reference internal" href="../kernel-features/"> 内核驱动支持的功能</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../man/8/ceph-fuse/"> ceph-fuse 手册页</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../man/8/mount.ceph/"> mount.ceph 手册页</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../man/8/mount.fuse.ceph/"> mount.fuse.ceph 手册页</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../#id6">CephFS 内幕</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id7">故障排除和灾难恢复</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id9">更多细节</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../rbd/">Ceph 块设备</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../monitoring/">监控概览</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/developer_guide/">开发者指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/internals/">Ceph 内幕</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../hardware-monitoring/">硬件监控</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <section id="fuse-cephfs">
<h1>用 FUSE 挂载 CephFS<a class="headerlink" href="#fuse-cephfs" title="Permalink to this heading"></a></h1>
<p>除了 <a class="reference internal" href="../mount-using-kernel-driver/#cephfs-mount-using-kernel-driver"><span class="std std-ref">CephFS 内核驱动</span></a> ，
<a class="reference external" href="../../man/8/ceph-fuse/#options">ceph-fuse</a> 是挂载 CephFS 的另外一种方法，
<a class="reference external" href="../../man/8/ceph-fuse/#options">ceph-fuse</a> 挂载是在用户空间运行的。这意味着，
<a class="reference external" href="../../man/8/ceph-fuse/#options">ceph-fuse</a> 挂载的性能相比内核驱动会低一些，
但它更容易管理、也容易升级。</p>
<section id="id1">
<h2>前提条件<a class="headerlink" href="#id1" title="Permalink to this heading"></a></h2>
<p>先走通二者都需要的先决条件，内核、 FUSE 挂载的，位于 <a class="reference external" href="../mount-prerequisites">挂载 CephFS ：先决条件</a> 。</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>通过 FUSE 挂载 CephFS 需要超级用户权限（ sudo/root ）。
libfuse 接口没有提供在内核中修剪缓存条目的机制，
因此需要用重新挂载（ <code class="docutils literal notranslate"><span class="pre">mount(2)</span></code> ）系统调用来强制内核丢弃缓存的元数据。
<code class="docutils literal notranslate"><span class="pre">ceph-fuse</span></code> 会周期性地发送重新挂载系统调用，
以回应 MDS 的缓存压力或元数据缓存撤销。</p>
</div>
</section>
<section id="id2">
<h2>提纲<a class="headerlink" href="#id2" title="Permalink to this heading"></a></h2>
<p>一般来说，通过 FUSE 挂载 CephFS 的命令是这样的：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><style type="text/css">
span.prompt1:before {
  content: "# ";
}
</style><span class="prompt1">ceph-fuse<span class="w"> </span><span class="o">{</span>mountpoint<span class="o">}</span><span class="w"> </span><span class="o">{</span>options<span class="o">}</span></span>
</pre></div></div></section>
<section id="cephfs">
<h2>挂载 CephFS<a class="headerlink" href="#cephfs" title="Permalink to this heading"></a></h2>
<p>要以 FUSE 方式挂载 Ceph 文件系统，用 <code class="docutils literal notranslate"><span class="pre">ceph-fuse</span></code> 命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mkdir</span> <span class="o">/</span><span class="n">mnt</span><span class="o">/</span><span class="n">mycephfs</span>
<span class="n">ceph</span><span class="o">-</span><span class="n">fuse</span> <span class="o">--</span><span class="nb">id</span> <span class="n">foo</span> <span class="o">/</span><span class="n">mnt</span><span class="o">/</span><span class="n">mycephfs</span>
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">--id</span></code> 选项传入的是 CephX 用户的名字，我们挂载 CephFS 时要用他的密钥环，
在这个命令里，他是 <code class="docutils literal notranslate"><span class="pre">foo</span></code> 。你也可以用 <code class="docutils literal notranslate"><span class="pre">-n</span></code> 代替，但 <code class="docutils literal notranslate"><span class="pre">--id</span></code> 显然更简单:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">fuse</span> <span class="o">-</span><span class="n">n</span> <span class="n">client</span><span class="o">.</span><span class="n">foo</span> <span class="o">/</span><span class="n">mnt</span><span class="o">/</span><span class="n">mycephfs</span>
</pre></div>
</div>
<p>如果密钥环不在标准位置下，你可以手动传入：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">fuse</span> <span class="o">--</span><span class="nb">id</span> <span class="n">foo</span> <span class="o">-</span><span class="n">k</span> <span class="o">/</span><span class="n">path</span><span class="o">/</span><span class="n">to</span><span class="o">/</span><span class="n">keyring</span> <span class="o">/</span><span class="n">mnt</span><span class="o">/</span><span class="n">mycephfs</span>
</pre></div>
</div>
<p>你也可以传入监视器地址，虽然这不是强制的：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">fuse</span> <span class="o">--</span><span class="nb">id</span> <span class="n">foo</span> <span class="o">-</span><span class="n">m</span> <span class="mf">192.168.0.1</span><span class="p">:</span><span class="mi">6789</span> <span class="o">/</span><span class="n">mnt</span><span class="o">/</span><span class="n">mycephfs</span>
</pre></div>
</div>
<p>你也可以只挂载 CephFS 里的某个特定目录，
而不是挂载 CephFS 的根目录：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">fuse</span> <span class="o">--</span><span class="nb">id</span> <span class="n">foo</span> <span class="o">-</span><span class="n">r</span> <span class="o">/</span><span class="n">path</span><span class="o">/</span><span class="n">to</span><span class="o">/</span><span class="nb">dir</span> <span class="o">/</span><span class="n">mnt</span><span class="o">/</span><span class="n">mycephfs</span>
</pre></div>
</div>
<p>如果你的 Ceph 集群有多个 FS ，可以用 <code class="docutils literal notranslate"><span class="pre">--client_fs</span></code> 选项挂载非默认的文件系统：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">fuse</span> <span class="o">--</span><span class="nb">id</span> <span class="n">foo</span> <span class="o">--</span><span class="n">client_fs</span> <span class="n">mycephfs2</span> <span class="o">/</span><span class="n">mnt</span><span class="o">/</span><span class="n">mycephfs2</span>
</pre></div>
</div>
<p>你也可以在 <code class="docutils literal notranslate"><span class="pre">ceph.conf</span></code> 里加上 <code class="docutils literal notranslate"><span class="pre">client_fs</span></code> 配置。
另外， <code class="docutils literal notranslate"><span class="pre">--client_mds_namespace</span></code> 选项可用于向后兼容。</p>
</section>
<section id="id3">
<h2>卸载 CephFS<a class="headerlink" href="#id3" title="Permalink to this heading"></a></h2>
<p>像其它文件系统一样，用 <code class="docutils literal notranslate"><span class="pre">umount</span></code> 卸载 CephFS:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">umount</span> <span class="o">/</span><span class="n">mnt</span><span class="o">/</span><span class="n">mycephfs</span>
</pre></div>
</div>
<div class="admonition tip">
<p class="admonition-title">Tip</p>
<p>执行此命令时需要确保你不在这个文件系统的目录里。</p>
</div>
</section>
<section id="id4">
<h2>永久挂载<a class="headerlink" href="#id4" title="Permalink to this heading"></a></h2>
<p>要把 CephFS 挂载成用户空间文件系统，在 <code class="docutils literal notranslate"><span class="pre">/etc/fstab</span></code> 里加上如下内容:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1">#DEVICE PATH       TYPE      OPTIONS</span>
<span class="n">none</span>    <span class="o">/</span><span class="n">mnt</span><span class="o">/</span><span class="n">mycephfs</span>  <span class="n">fuse</span><span class="o">.</span><span class="n">ceph</span> <span class="n">ceph</span><span class="o">.</span><span class="n">id</span><span class="o">=</span><span class="p">{</span><span class="n">user</span><span class="o">-</span><span class="n">ID</span><span class="p">}[,</span><span class="n">ceph</span><span class="o">.</span><span class="n">conf</span><span class="o">=</span><span class="p">{</span><span class="n">path</span><span class="o">/</span><span class="n">to</span><span class="o">/</span><span class="n">conf</span><span class="o">.</span><span class="n">conf</span><span class="p">}],</span><span class="n">_netdev</span><span class="p">,</span><span class="n">defaults</span>  <span class="mi">0</span> <span class="mi">0</span>
</pre></div>
</div>
<p>例如:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">none</span>    <span class="o">/</span><span class="n">mnt</span><span class="o">/</span><span class="n">mycephfs</span>  <span class="n">fuse</span><span class="o">.</span><span class="n">ceph</span> <span class="n">ceph</span><span class="o">.</span><span class="n">id</span><span class="o">=</span><span class="n">myuser</span><span class="p">,</span><span class="n">_netdev</span><span class="p">,</span><span class="n">defaults</span>  <span class="mi">0</span> <span class="mi">0</span>
<span class="n">none</span>    <span class="o">/</span><span class="n">mnt</span><span class="o">/</span><span class="n">mycephfs</span>  <span class="n">fuse</span><span class="o">.</span><span class="n">ceph</span> <span class="n">ceph</span><span class="o">.</span><span class="n">id</span><span class="o">=</span><span class="n">myuser</span><span class="p">,</span><span class="n">ceph</span><span class="o">.</span><span class="n">conf</span><span class="o">=/</span><span class="n">etc</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">foo</span><span class="o">.</span><span class="n">conf</span><span class="p">,</span><span class="n">_netdev</span><span class="p">,</span><span class="n">defaults</span>  <span class="mi">0</span> <span class="mi">0</span>
</pre></div>
</div>
<p>这里用的是 ID （如 <code class="docutils literal notranslate"><span class="pre">myuser</span></code> ，不是 <code class="docutils literal notranslate"><span class="pre">client.myuser</span></code> ）。
你可以这样给命令行加上任意的合法 <code class="docutils literal notranslate"><span class="pre">ceph-fuse</span></code> 选项。</p>
<p>要挂载 CephFS 的一个子目录，把下面的加进 <code class="docutils literal notranslate"><span class="pre">/etc/fstab</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">none</span>    <span class="o">/</span><span class="n">mnt</span><span class="o">/</span><span class="n">mycephfs</span>  <span class="n">fuse</span><span class="o">.</span><span class="n">ceph</span> <span class="n">ceph</span><span class="o">.</span><span class="n">id</span><span class="o">=</span><span class="n">myuser</span><span class="p">,</span><span class="n">ceph</span><span class="o">.</span><span class="n">client_mountpoint</span><span class="o">=/</span><span class="n">path</span><span class="o">/</span><span class="n">to</span><span class="o">/</span><span class="nb">dir</span><span class="p">,</span><span class="n">_netdev</span><span class="p">,</span><span class="n">defaults</span>  <span class="mi">0</span> <span class="mi">0</span>
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">ceph-fuse&#64;.service</span></code> 和 <code class="docutils literal notranslate"><span class="pre">ceph-fuse.target</span></code> systemd unit 默认可用。
和往常一样，这些 unit 文件声明了默认的依赖关系和建议的 <code class="docutils literal notranslate"><span class="pre">ceph-fuse</span></code> 执行上下文。
写好上面的 fstab 条目后，运行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">systemctl</span> <span class="n">start</span> <span class="n">ceph</span><span class="o">-</span><span class="n">fuse</span><span class="o">@/</span><span class="n">mnt</span><span class="o">/</span><span class="n">mycephfs</span><span class="o">.</span><span class="n">service</span>
<span class="n">systemctl</span> <span class="n">enable</span> <span class="n">ceph</span><span class="o">-</span><span class="n">fuse</span><span class="o">.</span><span class="n">target</span>
<span class="n">systemctl</span> <span class="n">enable</span> <span class="n">ceph</span><span class="o">-</span><span class="n">fuse</span><span class="o">@-</span><span class="n">mnt</span><span class="o">-</span><span class="n">mycephfs</span><span class="o">.</span><span class="n">service</span>
</pre></div>
</div>
<p>关于 CephX 用户管理的细节见 <a class="reference internal" href="../../rados/operations/user-management/#user-management"><span class="std std-ref">用户管理</span></a> ，
<a class="reference external" href="../../man/8/ceph-fuse/#options">ceph-fuse</a> 手册里有它支持的更多选项。
故障排除请参考 <a class="reference internal" href="../troubleshooting/#ceph-fuse-debugging"><span class="std std-ref">ceph-fuse 的调试</span></a> 。</p>
</section>
</section>



<div id="support-the-ceph-foundation" class="admonition note">
  <p class="first admonition-title">Brought to you by the Ceph Foundation</p>
  <p class="last">The Ceph Documentation is a community resource funded and hosted by the non-profit <a href="https://ceph.io/en/foundation/">Ceph Foundation</a>. If you would like to support this and our other efforts, please consider <a href="https://ceph.io/en/foundation/join/">joining now</a>.</p>
</div>


           </div>
           
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="../mount-using-kernel-driver/" class="btn btn-neutral float-left" title="用内核驱动挂载 CephFS" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="../ceph-dokan/" class="btn btn-neutral float-right" title="在 Windows 上挂载 CephFS" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).</p>
  </div>

   

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>